#!/bin/bash

# Check if number of files is provided
if [ $# -ne 1 ]; then
    echo "Usage: $0 <number_of_files>"
    exit 1
fi

# Create pdf directory if it doesn't exist
mkdir -p ./pdf

# Get the number of files to copy
n=$1

# Copy the latest n PDF files from Downloads to ./pdf/
ls -t ~/Downloads/*.pdf | head -n "$n" | while read -r file; do
    cp "$file" ./pdf/
done

echo "Copied latest $n PDF files from ~/Downloads/ to ./pdf/"